//
//  HEServerOrgCell.m
//  HealthElderly
//
//  Created by 吴欧 on 2021/5/25.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HEServerOrgCell.h"
#import "HEServerOrgModel.h"

@interface HEServerOrgCell ()

@property (nonatomic, strong) UIImageView *orgImgView;
@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *descLb;
@property (nonatomic, strong) UILabel *addressLb;
@end

@implementation HEServerOrgCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = CViewBgColor;
        [self initUI];
    }
    return self;
}

- (void)initUI {
     
    UIView *warp = [UIView new];
    warp.backgroundColor = KWhiteColor;
    warp.layer.cornerRadius = 10;
    [self.contentView addSubview:warp];
     
    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(10);
        make.left.equalTo(self.contentView).mas_offset(20);
        make.right.equalTo(self.contentView).mas_offset(-20);
        make.bottom.equalTo(self.contentView).mas_offset(-0);
    }];
    
    // 商品图片
    _orgImgView = [UIImageView new];
    _orgImgView.contentMode = UIViewContentModeScaleAspectFill;
    [warp addSubview:_orgImgView];
    
 
    _titleLb = [UILabel new];
    _titleLb.text = @"-";
    _titleLb.font = DYBlodFont(18);
    _titleLb.numberOfLines = 0;
    [warp addSubview:_titleLb];
    
    _descLb = [UILabel new];
    _descLb.text = @"-";
    _descLb.font = DYFont(15);
    _descLb.numberOfLines = 2;
    _descLb.textColor = CNavLightBlackColor;
    [warp addSubview:_descLb];
    
    _addressLb = [UILabel new];
    _addressLb.text = @"-";
    _addressLb.font = DYFont(15);
    _addressLb.numberOfLines = 0;
    _addressLb.textColor = CNavLightBlackColor;
    [warp addSubview:_addressLb];
    
    [_orgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(warp);
        make.left.equalTo(warp).offset(15);
        make.width.height.offset(100);
    }];
    [_orgImgView hg_setAllCornerWithCornerRadius: 8];

    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).offset(15);
        make.left.equalTo(_orgImgView.mas_right).mas_offset(11);
        make.right.equalTo(warp).mas_offset(-11);
    }];
    
    [_descLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).offset(15);
        make.left.equalTo(_orgImgView.mas_right).mas_offset(11);
        make.right.equalTo(warp).mas_offset(-10);
    }];
    
    [_addressLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_descLb.mas_bottom).offset(15);
        make.left.equalTo(_orgImgView.mas_right).mas_offset(11);
        make.right.equalTo(warp).mas_offset(-10);
        make.bottom.equalTo(warp).mas_offset(-10);
    }];
 
}
 
- (void)configCellWithModel:(HEServerOrgModel *)model indexPath:(NSIndexPath *)indexPath {
    [_orgImgView sd_setImageWithURL:[NSURL URLWithString:model.depart_logo] placeholderImage:IMAGE_NAMED(@"noImage")];
    _titleLb.text = model.hospital_name;
    _descLb.text = model.desc;
    _addressLb.text = model.address;
}

@end
